Skip to content

Refactor non-schema errors with thiserror - #7

Merged
yslib merged 11 commits into
mainfrom
feature/thiserror-wrapper-refactor
Jul 29, 2026
Merged

Refactor non-schema errors with thiserror#7
yslib merged 11 commits into
mainfrom
feature/thiserror-wrapper-refactor

Conversation

@yslib

@yslib yslib commented Jul 29, 2026

Copy link
Copy Markdown
Owner

Summary

  • add thiserror 2 and replace handwritten Display, Error, and mechanical From implementations for all 20 non-schema error types
  • preserve immediate typed Error::source() chains while keeping source-less domain errors source-less
  • consolidate four private app-command wrappers into two shared internal boundaries
  • derive JobSelectionError display from the canonical typed job selector
  • add a comprehensive source/no-source characterization suite, including runtime-only failure variants and the complete config-validation source chain
  • retain handwritten Display only where formatting remains genuinely procedural

Why

The error model had accumulated repetitive trait implementations across action, provider, planning, validation, configuration, link, and app-command modules. This refactor makes the type declarations the error contract while preserving the existing domain boundaries and runtime behavior.

The final cleanup also removes duplicate private command wrappers and makes unknown-job diagnostics use the same canonical package:id, action:id, and link:id spelling accepted by the CLI.

Intentional API changes

Three public field representations change to work with thiserror while retaining concrete immediate-source downcasts:

  • LinkError::UnsupportedSourceType.source is renamed to .path because thiserror reserves a field named source for error chaining
  • ConfigValidationError.kind changes from Box<ConfigValidationErrorKind> to direct ConfigValidationErrorKind
  • ConfigLoadError::Validation.source changes from Box<ConfigValidationError> to direct ConfigValidationError

The two direct errors are larger, so the affected validation, configuration, and app modules use documented #[expect(clippy::result_large_err)] attributes. These expectations fail under strict Clippy if they become unnecessary.

JobSelectionError::Unknown keeps its public variant shape but changes its display from kind-specific prose such as “unknown action job unknown” to the canonical form “unknown job action:unknown”.

Impact

  • command flow and schema.rs are unchanged
  • production and dependency code removes 608 net lines
  • the test suite adds 582 net lines to characterize every migrated source-bearing and source-less variant
  • no transparent errors or unintended public conversion APIs are introduced

Validation

  • cargo fmt --all -- --check
  • cargo clippy --locked --all-targets --all-features -- -D warnings
  • cargo test --locked --all-targets --all-features — 315 top-level tests passed
  • pinned Rust 1.96.1 Windows GNU cross-target Clippy for x86_64-pc-windows-gnu with all targets and features
  • static audits for all 20 derives, 8 expected #[from] attributes, zero transparent errors, unchanged schema.rs, ignored process docs, and a clean worktree

@yslib yslib changed the title Refactor wrapper errors with thiserror Refactor non-schema errors with thiserror Jul 29, 2026
@yslib
yslib marked this pull request as ready for review July 29, 2026 11:38
@yslib
yslib merged commit 9f7866e into main Jul 29, 2026
7 checks passed
@yslib
yslib deleted the feature/thiserror-wrapper-refactor branch July 31, 2026 01:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant